import { Component, OnInit } from '@angular/core';
import { Router } from '@angular/router';

@Component({
  selector: 'app-refresher',
  templateUrl: './refresher.page.html',
  styleUrls: ['./refresher.page.scss'],
})
export class RefresherPage implements OnInit {

  datalist = [
    {
      name: '蜘蛛侠：平行宇宙',
      unread: true
    },
    {
      name: '三次元女友',
      unread: true
    },
    {
      name: '无名之辈',
      unread: true
    },
    {
      name: '惊奇队长',
      unread: true
    },
    {
      name: '绿皮书',
      unread: true
    },
    {
      name: '夏目友人帐',
      unread: true
    },
    {
      name: '驯龙高手3',
      unread: true
    },
    {
      name: '阿丽塔：战斗天使',
      unread: true
    }
  ];

  newsdatalist:any = []

  constructor(private router: Router) { }

  ngOnInit() {
  }

  gotohome(){
    this.router.navigate(['/tabs/tab3'])
  }

  doRefresh(event) {
    setTimeout(() => {
      this.prependMessages(5, true);
      event.target.complete();
    }, 2000);
  }

  prependMessages(numMessages = 1, unread) {
    var arr = [];
    for (let i = 0; i < numMessages; i++) {
      var data1 = {name:'驯龙高手3', unread: false};
      arr.push(data1);
    }
    this.datalist = this.datalist.concat(arr);
  }

 

}
